package com.tanhua.admin.task;

import com.tanhua.admin.service.AnalysisByDayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author げっしょく
 * @date 2021/11/5
 */
@Component
public class AnalysisTask {

    @Autowired
    private AnalysisByDayService analysisByDayService;

    @Scheduled(cron = "0 0 * * * ?")
    public void analysis() {
        try {
            String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
            System.out.println("当前时间是: " + time);
            analysisByDayService.analysis();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    //@Scheduled(cron = "0/5 * * * * ?")
    public void anal() {
        String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
        System.out.println("当前时间: " + time);
    }
}
